<?php

defined('MYLITS') ? '' : exit('No direct script access allowed');

/**
 * @version     1.0.0
 * @package     mylits engine
 * @license     GNU General Public License version 3
 * @author      Arfan Fudyartanto D N <arfan@mylits.com> - http://engine.mylits.com
 */
class crudProcess extends Mylits_Process {

    function __construct() {
        parent::__construct();
        $this->setTemplate('crud');
        $this->loadHelper('devel');
    }

    public function response() {
        $result = false;
        $previx = $_POST['prefix'];
        $name = $_POST['name'];
        if (!empty($previx)) {
            $componentName = 'comp.' . $previx . '.' . $name;
        } else {
            $componentName = 'comp.' . $name;
        }
        if (!empty($name)) {
            $crudPath = $this->getComponentPath() . 'assets/comp.tpl/';
            $componentPath = APP_DIR . 'components/' . $componentName . '/';

            $result = develHelper::copyReplace($crudPath, $componentPath);
        }
        if ($result) {
            $msgClass = 'success';
            $msg = Mylits_Language::getText('success');
        } else {
            $msgClass = 'warning';
            $msg = Mylits_Language::getText('failed');
        }
        exit;
        Mylits_System::addSystemMsg($msgClass, $msg);
        Mylits_System::redirect($this->getComponentName() . '/view.crud');
    }

}

?>
